package cn.wolfcode.crm.Service.impl;


import cn.wolfcode.crm.Service.ICustomerService;
import cn.wolfcode.crm.domain.Customer;
import cn.wolfcode.crm.domain.Employee;
import cn.wolfcode.crm.mapper.CustomerMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CustomerServiceImpl implements ICustomerService {
    @Autowired
    private CustomerMapper customerMapper;


    @Override
    public int insert(Customer record) {
        //封装客户的录入人
        record.setInputUser(UserContext.getEmployee());
        //封装客户的录入时间
        record.setInputTime(new Date());
        int i = customerMapper.insert(record);
        return  i;
    }



    @Override
    public int updateByPrimaryKey(Customer record) {
        int i = customerMapper.updateByPrimaryKey(record);
        return i;
    }

    @Override
    public PageInfo<Customer> queryForList(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Customer> list = customerMapper.queryForList(qo);
        return new PageInfo<>(list);
    }

    @Override
    public void changeStatus(Long cid, int status) {
        customerMapper.updateStatus(cid,status);
    }


}




















